package org.infodavid.common.model.impl;

import java.io.Serializable;

/**
 * The Class AbstractImprovedDataObjectImpl.
 * @param <K> the key type
 */
public abstract class AbstractImprovedDataObjectImpl<K extends Serializable> extends
    AbstractDataObjectImpl<K> {

  /** serialVersionUID. */
  private static final long serialVersionUID = -1682330418928589184L;

  /**
   * Instantiates a new abstract improved data object impl.
   * @throws Exception the exception
   */
  public AbstractImprovedDataObjectImpl() throws Exception {
    super();
  }

  /**
   * Instantiates a new abstract improved data object impl.
   * @param keyArg the key arg
   * @throws Exception the exception
   */
  public AbstractImprovedDataObjectImpl(K keyArg) throws Exception {
    super(keyArg);
  }

  /*
   * (non-Javadoc)
   * @see org.infodavid.common.model.IDataObject#markModified(java.lang.String, java.lang.Object,
   * java.lang.Object)
   */
  @Override
  public void markModified(final String property, final Object oldValue, final Object newValue) {
    if (isModificationTrackingEnabled()) {
      final PoolablePropertyChangeEvent evt = PropertyChangeEventFactory.getSingleton().borrow();
      evt.setSource(this);
      evt.setPropertyName(property);
      evt.setOldValue(oldValue);
      evt.setNewValue(newValue);

      super.markModified(evt.getPropertyName());
      getChangeSupport().firePropertyChange(evt);
    }
  }
}
